/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package gui;

import static gui.Index.vipB;

/**
 *
 * @author Evistix
 */
public class Login extends javax.swing.JDialog {

    /**
     * Creates new form Login
     */
    public Login(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
         this.setIconImage(java.awt.Toolkit.getDefaultToolkit().createImage((getClass().getResource("/icon/nailuo.jpg"))));
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        用户名 = new javax.swing.JTextField();
        密码 = new javax.swing.JPasswordField();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        注册 = new javax.swing.JButton();
        登录 = new javax.swing.JButton();
        返回 = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("登录");
        getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        用户名.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                用户名ActionPerformed(evt);
            }
        });
        getContentPane().add(用户名, new org.netbeans.lib.awtextra.AbsoluteConstraints(130, 80, 210, -1));
        getContentPane().add(密码, new org.netbeans.lib.awtextra.AbsoluteConstraints(130, 140, 210, -1));

        jLabel2.setFont(new java.awt.Font("宋体", 1, 18)); // NOI18N
        jLabel2.setText("密  码：");
        getContentPane().add(jLabel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(60, 140, -1, -1));

        jLabel3.setFont(new java.awt.Font("宋体", 1, 18)); // NOI18N
        jLabel3.setText("用户名：");
        getContentPane().add(jLabel3, new org.netbeans.lib.awtextra.AbsoluteConstraints(60, 80, -1, -1));

        注册.setText("注册");
        注册.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                注册ActionPerformed(evt);
            }
        });
        getContentPane().add(注册, new org.netbeans.lib.awtextra.AbsoluteConstraints(180, 210, -1, -1));

        登录.setText("登录");
        登录.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                登录ActionPerformed(evt);
            }
        });
        getContentPane().add(登录, new org.netbeans.lib.awtextra.AbsoluteConstraints(90, 210, -1, -1));

        返回.setText("返回");
        返回.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                返回ActionPerformed(evt);
            }
        });
        getContentPane().add(返回, new org.netbeans.lib.awtextra.AbsoluteConstraints(280, 210, -1, -1));

        jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/background/bg1.png"))); // NOI18N
        jLabel1.setText("jLabel1");
        getContentPane().add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 490, 360));

        pack();
        setLocationRelativeTo(null);
    }// </editor-fold>//GEN-END:initComponents

    private void 用户名ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_用户名ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_用户名ActionPerformed

    private void 登录ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_登录ActionPerformed
        // TODO add your handling code here:
         if(用户名.getText().equals("")) javax.swing.JOptionPane.showMessageDialog(rootPane,"请输入用户名"); 
         else if(密码.getText().equals("")) javax.swing.JOptionPane.showMessageDialog(rootPane,"请输入密码"); 
         else {
             Index.login=1;
             Index.欢迎.setText("尊敬的 "+用户名.getText()+" 欢迎使用");
             Index.头像.setVisible(true);
             Index.欢迎.setVisible(true);
             Index.退出登录.setVisible(true);
             vipB.setVisible(true);
             this.setVisible(false);
         }
    }//GEN-LAST:event_登录ActionPerformed

    private void 注册ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_注册ActionPerformed
        // TODO add your handling code here:
        this.setVisible(false);
        new Register().setVisible(true);
    }//GEN-LAST:event_注册ActionPerformed

    private void 返回ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_返回ActionPerformed
        // TODO add your handling code here:
         this.setVisible(false);
        
    }//GEN-LAST:event_返回ActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(Login.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(Login.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(Login.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(Login.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the dialog */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                Login dialog = new Login(new javax.swing.JFrame(), true);
                dialog.addWindowListener(new java.awt.event.WindowAdapter() {
                    @Override
                    public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
                    }
                });
                dialog.setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JPasswordField 密码;
    private javax.swing.JButton 注册;
    private javax.swing.JTextField 用户名;
    private javax.swing.JButton 登录;
    private javax.swing.JButton 返回;
    // End of variables declaration//GEN-END:variables
}
